<%@ page language="java" pageEncoding="UTF-8" %>
<%@ include file="/commons/jsp/taglibs.jsp" %>
<%@taglib uri="http://www.framework.com/taglib/tree" prefix="tree" %>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<style type="text/css">
    li {
        padding-top: 8px;
    }
</style>
<form name="addCancelDataForm" id="addCancelResonForm" method="post" action="">
    <input id="projectId" type="hidden" name="projectId" value="${projectId}"/>
    <input type="hidden" name="budgetMenuData" id="budgetMenuData" value=""/>
    <table class="infoTable">
        <tbody>
        <tr>
            <th style="width: 48px">竞拍结果</th>
            <td colspan="2">
                ${auctionCompareBid==null?"无人竞拍自动流标":title}
            </td>
        </tr>
        <tr>
            <th>选择状态</th>
            <td colspan="2">
                <span ${auctionCompareBid==null?"style='display: none'":""}>
                通过<input type="radio" name="status"
                         value="0" ${auctionCompareBid==null?"":"checked"}/>
                流标<input type="radio" name="status"
                         value="1"/>
                </span>
                <span ${auctionCompareBid==null?"":"style='display: none'"}>
                自动流标<input type="radio" name="status"
                           value="2" ${auctionCompareBid==null?"checked":""}/>
                       </span>
            </td>
        </tr>
        <tr>
            <th>填写原因</th>
            <td colspan="2">
        <textarea id="confirmReason" name="confirmReason"
                  style="width: 497px;"
                  rows="6" type="text" maxlength="200" value="">${auctionCompareBid==null?"无人竞拍自动流标":""}</textarea>
            </td>
        </tr>
        <tr>
            <th>评审纪要</th>
            <td style="width: 280px;border-right-style: none;">
                <a class="easyui-linkbutton" onclick="review();" target="_blank">评审纪要打印</a>
                <div id="fileQueue11" style="margin: 10px 0px 0px 10px" flag="11" class="fileQueue">
                    <input type="file" name="uploadify" class="uploadify" id="uploadify11"
                           data-options="required:true"/>
                    <p style="color: #aaaaaa;width: auto">
                        1、按住Ctrl可选择多个文件上传;<br/>
                        2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
                    </p>
                </div>
            </td>
            <td id="resDataList" style="border-left-style: none;">
                <c:forEach items="${resList}" var="res">
                    <div><a class="easyui-linkbutton"
                            href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);">${res.oldName}</a>
                        <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img
                                src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
                </c:forEach>
            </td>
        </tr>
        <tr>
            <th>其他资料</th>
            <td style="width: 280px;border-right-style: none;">
                <div id="fileQueue12" style="margin: 10px 0px 0px 10px" flag="12" class="fileQueue">
                    <input type="file" name="uploadify" class="uploadify" id="uploadify12"
                           data-options="required:true"/>
                    <p style="color: #aaaaaa;width: auto">
                        1、按住Ctrl可选择多个文件上传;<br/>
                        2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
                    </p>
                </div>
            </td>
            <td id="otherResDataList" style="border-left-style: none;">
                <c:forEach items="${otherResList}" var="otherRes">
                    <div><a class="easyui-linkbutton"
                            href="javascript:showOpenFile('${ctx }','${otherRes.id}',requestUrl);">${otherRes.oldName}</a>
                        <span style="cursor: pointer;" onclick="deleteFile(this,'${otherRes.id}');"><img
                                src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
                </c:forEach>
            </td>
        </tr>
        </tbody>
    </table>
</form>

<script type="text/javascript">
    $(function () {
        parent.$('#addEntityBt').hide();
        var resIds = "";
        <c:forEach items="${resList}" var="res">
        resIds += ",${res.id}";
        </c:forEach>

        <c:forEach items="${otherResList}" var="otherRes">
        resIds += ",${otherRes.id}";
        </c:forEach>
        $('#budgetMenuData').val(resIds);

        $(".uploadify").each(function () {
            $(this).uploadify({
                'height': 27,
                'width': 80,
                'buttonText': '选择附件',
                //'queueID': fileQueue.val(),//队列的ID
                'queueSizeLimit': 5,// 附件附列长度
                'swf': '${ctx}/commons/js/uploadify/uploadify.swf',
                'uploader': '${ctx}/business/projectmanage/upload;jsessionid=${pageContext.session.id}',// 上传时请求的后台处理的controller
                'cancelImg': '${ctx}/commons/js/uploadify/uploadify-cancel.png',
                'method': 'post',
                'folder': '',
                'preventCaching': true,
                'fileTypeExts': '*.jpg;*.png;*.gif;*.bmp;*.pdf',
                'auto': true,
                'multi': true,//是否可多选
                'removeCompleted': false,
                'successTimeout': 55555,
                'onUploadSuccess': function (file, data, response) {
                    $('#' + file.id).find('.data').html(' 上传完毕');
                    $('#budgetMenuData').val($('#budgetMenuData').val() + "," + data);
                    //alert("ww"+$('#' + file.id).parent().html());
                    //alert(file.id);
                    var cancel = $('.fileQueue .uploadify-queue-item[id="' + file.id + '"]').find(".cancel a");
                    if (cancel) {
                        cancel.attr("rel", data);
                        cancel.click(function () {
                            var cancelData = cancel.attr("rel");
                            var budgetMenuData = $('#budgetMenuData').val();
                            var index = budgetMenuData.indexOf("," + cancel.attr("rel"))
                            if (index != -1) {
                                budgetMenuData = budgetMenuData.replace("," + cancelData, "");
                                $('#budgetMenuData').val(budgetMenuData);
                            }
                        });
                    }
                },
                'onUploadStart': function (file) {
                    //alert("ww"+$('#' + file.id).parent().parent().find(".uploadify").attr("id"));
                    var uploadId = $('#' + file.id).parent().parent().find(".uploadify").attr("id");
                    //var params=$('#' + file.id).parent().parent().parent().parent().find(".fileName").val();
                    var functionFlog = $('#' + file.id).parent().parent().parent().parent().find(".fileQueue").attr("flag");
                    //alert(uploadId);
                    //alert(functionFlog);
                    $("#" + uploadId).uploadify("settings", "formData", {"functionFlog": functionFlog});
                },
                'onSelectError': function (file, errorCode, errorMsg) {
                    //alert(errorCode);
                    switch (errorCode) {
                        case -110:
                            //this.queueData.errorMsg="文件 ["+file.name+"] 大小超出系统限制的"+$('#file_upload').uploadify('settings','fileSizeLimit')+"大小！";
                            this.queueData.errorMsg = '所选文件大小超出系统限制!';
                            break;
                        case -120:
                            //this.queueData.errorMsg="文件 ["+file.name+"] 大小异常！"
                            this.queueData.errorMsg = '所选文件大小异常!';
                            break;
                        case -130:
                            //this.queueData.errorMsg="文件 ["+file.name+"] 类型不正确！"
                            this.queueData.errorMsg = '所选文件类型不正确!';
                            break;
                    }
                },
                'onCancel': function (file) {
                    //alert(file);
                }
            });
        });
    });
    function deleteFile(v, resId) {
        var parent = v.parentNode;
        parent.parentNode.removeChild(parent);
        var budgetMenuData = $('#budgetMenuData').val();
        var index = budgetMenuData.indexOf("," + resId)
        if (index != -1) {
            budgetMenuData = budgetMenuData.replace("," + resId, "");
            $('#budgetMenuData').val(budgetMenuData);
        }
    }

    /*评审纪要*/
    function review() {
        var id = $("#projectId").val();
        window.open("${ctx}/auctionBid/business/owner/reviewRecord?projectId=" + id);
    }
</script>
		